package com.ruoyi.web.controller.center;

import ch.qos.logback.core.net.SyslogOutputStream;
import com.ruoyi.RDcenter.common.Result;
import com.ruoyi.RDcenter.domain.ProductCenterVo;
import com.ruoyi.RDcenter.service.ProductCenterService;
import com.ruoyi.common.annotation.Anonymous;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;

/**
 * 研发中心
 *
 * @author ruoyi
 */
@Anonymous
@RestController
@RequestMapping("/productCenter")
@Api(tags = "研发中心接口")
@Slf4j
public class ProductCenterController {

    @Autowired
    private ProductCenterService productCenterService;

    /**
     * 研发产品展示
     * @return
     */
    @Anonymous
    @GetMapping("/getProducts")
    @ApiOperation("研发产品展示")
    public Result<Map<String,Object>> getProducts() {
        Map<String,Object> productCenterMap= productCenterService.getproductCenterMap();
//        System.out.println(productCenterMap);
        return Result.success(productCenterMap);
    }
    /**
     * 研发产品搜索
     * @return
     */
    @Anonymous
    @PostMapping("/findPrdByNameOrPrdName")
    @ApiOperation("研发产品搜索")
    public Result<Map<String,Object>> findPrdByNameOrPrdName(@RequestBody Map<String, String> request) {
        String searchWord = request.get("searchWord");
        Map<String,Object> productCenterMap= productCenterService.selectproductCenterMap(searchWord);
        return Result.success(productCenterMap);
    }
    /**
     * 获取产品详细信息
     * @return
     */
    @Anonymous
    @PostMapping("/findPrdById")
    @ApiOperation("获取产品详细信息")
    public Result<ProductCenterVo> findPrdById(@RequestBody Map<String, String> request) {
        String id = request.get("id");
        ProductCenterVo productCenterVo= productCenterService.findPrdById(id);
        return Result.success(productCenterVo);
    }
}
